<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
var geocoder;
var map;
var marker;
function initialize(){
	var latlng = new google.maps.LatLng(<?php echo $latitude?>,<?php echo $longitude?>);
	var options = {
		zoom: 13,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map-canvas"), options);
	geocoder = new google.maps.Geocoder();
	marker = new google.maps.Marker({
		map: map,
		position:latlng,
		draggable: true
	});
	google.maps.event.addListener(marker, 'dragend', function() {
		geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) {
		  if (status == google.maps.GeocoderStatus.OK) {
			if (results[0]) {
			  $('#latitude').val(marker.getPosition().lat());
			  $('#longitude').val(marker.getPosition().lng());
			}
		  }
		});
	});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style type="text/css">
      #map-canvas {
        width: 100%;
        height: 500px;
      }
</style>
<div class="left"></div>
<div class="right"></div>
<div class="heading">
	<h1 style="background-image: url('<?php echo base_url()?>assets/images/order.png');">Master Data</h1>
</div>
<div class="yui-gc wrapper">
<h1>Lokasi</h1>
<form action="" method="post" enctype="multipart/form-data">
    <div class="yui-u first">
        <div id="map-canvas"></div>
    </div>
	<div class="yui-u">
		<fieldset>
		<legend>Edit Data Lokasi</legend>
		<ul>
			<li>
				<label for="latitude">Latitude</label>
				<?php echo form_error('latitude', '<div class="error">', '</div>'); ?>
				<input type="text" id="latitude" name="latitude" class="title" value="<?php echo $latitude; ?>">
			</li>
				<label for="longitude">Longitude</label>
				<?php echo form_error('longitude', '<div class="error">', '</div>'); ?>
				<input type="text" id="longitude" name="longitude" class="title" value="<?php echo $longitude; ?>">
			<li>
				<input type="submit" value="Simpan" class=""> atau <?php echo anchor('backend/lokasi','Batal')?>
			</li>
		</ul>
		</fieldset>
		
	</div>
</form>
</div>